<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>多tab点击切换练习</title>
    <link rel="stylesheet" href="../../css/reset.css">
    <script src="../../js/common.js" type="text/javascript"></script>

    <style>
        #tab ul>li{
            display: inline-flex;
            flex-direction: row;
            margin: 0 10px;
        }
        #tab ul>li:nth-child(1){
            background-color: yellow;
        }
        #tab ul>li:nth-child(2){
            background-color: aquamarine;
        }
        #tab ul>li:nth-child(3){
            background-color: red;
        }
        #contains>div{
            width: 200px;
            height: 150px;
            text-align: center;
            background-color: #777777;
        }
    </style>
    <script type="text/javascript">
        $(()=>{
            $('#contains>div').css("display","none");
            $('#contains>div:first').css("display","");
            $('#tab ul>li').click(function (event){
                event = event || window.event;
                let name = event.target.className;
                $('#'+name).css("display","");
                $("#contains>div:not(#"+name+")").css("display","none");
            });

        });
    </script>
</head>
<body>
<div id="tab">
    <ul>
        <li class="contain1">套餐1</li>
        <li class="contain2">套餐2</li>
        <li class="contain3">套餐3</li>
    </ul>
</div>
<div id="contains">
    <div id="contain1">爽</div>
    <div id="contain2">真爽</div>
    <div id="contain3">真爽啊</div>
</div>
</body>
</html>